/* ============================================================================================
Abstract Data Type(ADT) is placed under the MIT license
Copyright (c) 2013 Ted Lin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================================================================*/

/* Define to prevent recursive inclusion*/
#ifndef _DLIST_H
#define _DLIST_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes */
#include <stdlib.h>
#include <assert.h>

typedef struct DList_tag DList;
typedef struct DListElmt_tag DListElmt;


extern DList* dlist_create(void (*destroy)(void* data));
extern void dlist_destroy(DList* list);

extern int dlist_ins_prev(DList* list, \
				   DListElmt* element, const void* data);
extern int dlist_ins_next(DList* list, \
				   DListElmt* element, const void* data);
extern int dlist_rmv(DList* list, \
			  DListElmt* element, void** data);

extern int dlist_size(const DList* list);
extern DListElmt* dlist_head(const DList* list);
extern DListElmt* dlist_tail(const DList* list);
extern int dlist_is_head(const DList* list, \
				  const DListElmt* element);
extern int dlist_is_tail(const DListElmt* element);

extern void* dlist_data(const DListElmt* element);
extern DListElmt* dlist_next(const DListElmt* element);
extern DListElmt* dlist_prev(const DListElmt* element);


#ifdef __cplusplus
}
#endif

#endif/* __DLIST_H */
/******************* (C) COPYRIGHT 2013 Ted Lin *****END OF FILE****/